<!-- 页面 -->
<template>
    <div class="xiang">
        <van-nav-bar @click-left="tui()" title="优选商城" style="background: red;" left-arrow />

        <van-row style="height: 200px;" v-for="(item,index) in list1" :key="index" @click="xiadd(item.goods_id)">
            <van-col span="8"><img :src=item.goods_small_logo alt=""></van-col>
            <van-col span="16">
                <p>{{ item.goods_name }}</p>
                <br>
                <p>{{ item.goods_price }}</p>
            </van-col>
        </van-row>
    </div>
</template>
<!-- vue -->
<script>
export default {
    data() {
        return {
            // 声明的属性
            list1: [],
            id11:'',
        }
    },
    //生命周期函数
    mounted() {
        this.id11 = JSON.parse(localStorage.getItem('id11'))
       

        this.$axios.get('https://api-hmugo-web.itheima.net/api/public/v1/goods/search', {
            params: {
                cid: this.id11
            }
        }).then(res => {
            res.data.message.goods.forEach(item => {
                this.list1.push(item)
            })

        })
    },
    // 调用方法
    methods: {
        tui() {
            this.$router.go(-1)
        },
        xiadd(idd){
            localStorage.setItem('idd',idd)
            this.$router.push('/xqing')
        }
    },
    // 监听器
    watch: {
    },
    // 计算属性
    computed: {
    },
    // 过滤器
    filters: {
    },
    // 自定义指令
    directives: {
    }
}
</script>
<!-- css样式 -->
<style>
.xiang {
    width: 100%;
    height: 100%;
}
.xiang img{
    width: 100%;
}
</style>